package net.oschina.arvin.dbjava.type;

import net.oschina.arvin.dbjava.model.Column;
import net.oschina.arvin.dbjava.util.DBJavaTypeMap;

import java.math.BigInteger;

/**
 * <pre>
 *     参考地址： https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-type-conversions.html
 *
 *     以下情况会被认为是 FLOAT 类型：
 *     1. FLOAT
 * </pre>
 *
 * @author Arvin
 * @time 2017/9/29 9:52
 */
public class FloatDBJavaTypeConverter implements DBJavaTypeConverter {

    @Override
    public Class<?> convertToJavaType(Column column, boolean toBoolForLenOneNumber, boolean useUtilDate, boolean wrapMode) {
        String dataType = column.getDataType().toUpperCase();
        if ("FLOAT".equals(dataType)) {
            return wrapMode ? Float.class : float.class;
        }
        return null;
    }

    @Override
    public String convertToDBColumnType(Class<?> javaType) {
        if (javaType == float.class || javaType == Float.class) {
            return "FLOAT";
        }
        return null;
    }
}
